﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace WindowsGame1
{
    class Object2D
    {

        private bool lockImage = true;
        private Texture2D image;
        public Texture2D Image
        {
            get { return image; }
            set { if (!lockImage) image = value; }
        }

        private Vector2 position;
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        private Vector2 scale;
        public Vector2 Scale
        {
            get { return scale; }
            set { scale = value; }
        }

        private Vector2 origin;
        public Vector2 Origin
        {
            get { return origin; }
            set { origin = value; }
        }

        private Color color;
        public Color ObjectColor
        {
            get { return color; }
            set { color = value; }
        }

        private Rectangle rect;
        public Rectangle Rect
        {

            get { return new Rectangle(rect.X,rect.Y, rect.Width * (int)scale.X, rect.Height * (int)scale.Y); }
            set { rect = value; }
        }

        private float rotation;
        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }

        private SpriteEffects effects;
        public SpriteEffects Effects
        {
            get { return effects; }
            set { effects = value; }
        }

        private float layerDepth;
        public float LayerDepth
        {
            get { return layerDepth; }
            set { layerDepth = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="image">Imagem para ser usada no objeto</param>
        /// <param name="lockImage">Verdadeiro se quer trancar imagem para nao poder editá-la depois</param>
        public Object2D(Texture2D image, bool lockImage)
        {
            this.lockImage = lockImage;
            this.image = image;
            scale = Vector2.One;
            rect = new Rectangle(0, 0, image.Width, image.Height);
            effects = SpriteEffects.None;
            layerDepth = 0;
            rotation = 0;
            origin = Vector2.Zero;
            position = Vector2.Zero;
            color = Color.White;
        }

        public virtual void Update(GameTime gt)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sp"></param>
        public void Draw(SpriteBatch sp)
        {
            sp.Draw(image, position, rect, color, rotation, origin, scale, effects, layerDepth);
        }
    }
}
